import axios from 'axios';

interface payType {
  tradeNo?: number;
  outTradeNo: number;
  totalAmount?: number;
  subject?: string;
}
export async function pay(params: payType) {
  const res = await axios.post('/api/pcpay', params);
  window.open(res.data, '_blank');
  // const payRes = axios.post('/api/pcpay/query', {
  //   outTradeNo: params.outTradeNo,
  // });
}
export async function payQuery(params: payType) {
  // const res = await axios.post('/api/pcpay', params);
  // location.href = res.data;
  const payRes = await axios.post('/api/pcpay/query', {
    outTradeNo: params.outTradeNo,
  });
  return payRes;
}

export default pay;
